home *** CD-ROM | disk | FTP | other *** search
- /****************************************************************************/
- /* Master-Guide */
- /* $VER: Master-Guide 1.2b (07.09.94) */
- /* */
- /* This program examines a directory to find AmigaGuide files. The guides */
- /* found will be put in one big guide, which are linked to the original */
- /* docs, it can work through subdirectories in a recursive way */
- /* */
- /* Bugs know in v1.1c: Will put directories in, which have no subdirs, or */
- /* Guides */
- /* */
- /* Author: Kenneth Fribert FidoNet: 2:235/317.0 */
- /* email: kfribert@scala.ping.dk */
- /* kfribert@kfribert.adsp.sub.org */
- /* kensaga@diku.dk */
- /* */
- /* This program is postcardware/emailware, what suits you the best, this */
- /* means that if you use it, you are obliged to send me a postcard or at */
- /* least an email. Gifts, cars etc. are welcome, but hey, this program */
- /* Aren't that big a deal :-) */
- /* */
- /* The program has the following arguments: */
- /* PATH/M ALL/S OUT=OUTPUT/K */
- /* Where Path is the place(s) to search for guides, 'ALL' is whether or not */
- /* it should work recursive, output is where to put the resulting guide and */
- /* the filename. */
- /****************************************************************************/
-
- Options Results
-
- Parse Arg Argumenter
- Signal On BREAK_C
- /*Signal On SYNTAX*/
-
- /****************************************************************************/
- /* Make arexx-port */
- /* Check that no other MasterGuide's are working */
- /****************************************************************************/
-
- If Show(P,'MasterGuide')~=0 Then
- Do
- Say ('MasterGuide is already working')
- Exit 5
- End
-
- If ~Exists('libs:rexxsupport.library') Then
- Do
- Say 'RexxSupport.library is needed, please install it in your libs: dir'
- Exit 10
- End
-
- If ~Show('L','rexxsupport.library') Then
- Call AddLib('rexxsupport.library',0,-30,0)
-
- Call OpenPort('MasterGuide')
- Headerfile='Rexx:Guide.Head'
- EndFile='Rexx:Guide.End'
-
- If ~Exists('libs:RexxDosSupport.library') Then
- Do
- Say 'RexxDosSupport.library is needed, please install it in your libs: dir'
- Exit 10
- End
-
- If ~Show('L','RexxDosSupport.library') Then
- Call AddLib('RexxDosSupport.library',0,-30)
-
-
- If ~Show('L','datatypes.library') Then
- Do
- Call AddLib('datatypes.library',0,-30,39)
- End
- UseDT=Exists('libs:datatypes.library')
-
- Template='PATH/M,ALL/S,TXT/S,OUT/K'
- Call ReadArgs(argumenter,template,"input.")
- If input.path.0=? Then
- Do
- Say Template
- Exit 0
- End
-
- If input.path.count=0 Then
- Do
- Say 'Search path for AmigaGuide files are missing!'
- Exit 10
- End
-
- If input.out='INPUT.OUT' Then
- input.out='Ram:MasterGuide'
-
-
- /****************************************************************************/
- /* Main program */
- /****************************************************************************/
- Do
- Call Header(input.out,HeaderFile)
- Call Multiple()
- Call EndGuide(EndFile)
- Call Closeport('MasterGuide')
- End
- Exit 0
-
-
-
- /****************************************************************************/
- /* If multiple drawers, then do a masterwindow first, otherwise just roll */
- /****************************************************************************/
-
- Multiple:
-
- Do i=0 to input.path.count-1
- If Right(input.path.i,1)~=":" & Right(input.path.i,1)~="/" Then
- input.path.i=input.path.i||"/"
- End
- If input.path.count=1 Then
- Call ParseDrawer(input.path.0,'Main',input.all)
- Else
- Do
- Maximum=0
- NavneListe=''
- Do i=0 to input.path.count-1
- NavneListe=NavneListe||input.path.i||' '
- If Length(input.path.i)>Maximum Then
- Maximum=Length(input.path.i)
- End
- ItemListe=NavneListe
- Call WriteLn('Master','')
- Call AppendGuide(Maximum,,'Drawer')
- Call WriteLn('Master','@EndNode')
- Do i=0 to input.path.count-1
- Call ParseDrawer(input.path.i,input.path.i,input.all)
- End
- End
- Return 0
-
-
- /****************************************************************************/
- /* Parse a whole drawer, including drawers and subdrawers */
- /****************************************************************************/
- ParseDrawer: Procedure Expose UseDT input.txt
- Parse Arg skuffe,DrawerLevel,Recurs
-
- If DrawerLevel~='Main' Then
- Call WriteLn('Master','@Node '||Compress(Skuffe,'/:'))
- Call WriteLn('Master','')
- Call WriteLn('Master',' '||Skuffe)
- Call WriteLn('Master','')
- Call MakeGuideList(skuffe)
- If Recurs Then
- Call MakeDrawerList(skuffe,Recurs)
- Else
- Call WriteLn('Master','@EndNode')
- Return 0
-
-
- /****************************************************************************/
- /* Make list over Guide's i drawer */
- /****************************************************************************/
-
- MakeGuideList: Procedure Expose UseDT input.txt
- Parse Arg Drawer
-
- Code3='03'x
- Count=1
- MaxLength=0
- NavneListe=''
- ItemListe=''
- Call Progress(Drawer)
- Liste=MShowDir(Drawer,FILE)
- Do While Count<=Words(Liste)
- Item=Word(Liste,Count)
- If Right(Item,5)~='.info' then
- Do
- If ~UseDT Then
- Do
- Call Open('Object',Drawer||StripM(Item),Read)
- If ('@DATABASE ' = Upper(ReadCh('Object',10))) Then
- Do
- If Right(Upper(Item),6)='.GUIDE' Then
- Navn=Left(Item,Length(Item)-6)
- Else
- Navn=Item
- If Length(Navn)>MaxLength Then
- MaxLength=Length(Navn)
- Navneliste=NavneListe||Navn||' '
- ItemListe=ItemListe||Item||' '
- End
- Call Close('Object')
- End
- Else
- Do
- If Word(Statef(Drawer||StripM(Item)),2)>0 then
- Do
- Type=ExamineDT(Drawer||StripM(Item),,'VAR')
- If Type='AmigaGuide'||'00'x | (input.txt & Type='ascii'||'00'x) Then
- Do
- If Right(Upper(Item),6)='.GUIDE' Then
- Navn=Left(Item,Length(Item)-6)
- Else
- Navn=Item
- If Length(Navn)>MaxLength Then
- MaxLength=Length(Navn)
- If Type='AmigaGuide'||'00'x & input.txt Then
- Navn=Navn||Code3
- Navneliste=NavneListe||Navn||' '
- ItemListe=ItemListe||Item||' '
- End
- End
- End
- End
- Count=Count+1
- End
- If Words(NavneListe)>0 Then
- Call AppendGuide(MaxLength,Drawer,'GUIDE')
- Return 0
-
-
- /****************************************************************************/
- /* Append drawers in drawer to Guide */
- /****************************************************************************/
-
- MakeDrawerList: Procedure Expose UseDT input.txt
- Parse Arg Skuffe,Recurs
-
- SkuffeListe=MShowDir(skuffe,DIR)
- SkuffeListe2=''
- If Words(SkuffeListe)=0 Then
- Do
- Call WriteLn('Master','@EndNode')
- Return 0
- End
- MaxLength=0
- Do i=1 to Words(skuffeliste)
- If WordLength(skuffeliste,i)>MaxLength Then
- MaxLength=WordLength(skuffeliste,i)
- Skuffeliste2=Skuffeliste2||Skuffe||Word(Skuffeliste,i)||' '
- End
- Call WriteLn('Master','')
- Call WriteLn('Master',' Skuffer:')
- NavneListe=SkuffeListe
- ItemListe=SkuffeListe2
- Call AppendGuide(MaxLength,Skuffe,'DRAWER')
- Call WriteLn('Master','@EndNode')
- Do i=1 to Words(skuffeliste)
- Call ParseDrawer(StripM(Word(SkuffeListe2,i))||'/',StripM(Word(SkuffeListe2,i))||'/',Recurs)
- End
- Return 0
-
-
- /****************************************************************************/
- /* Put header on outputguide */
- /****************************************************************************/
-
- Header: Procedure
- Parse Arg OutFile,HeaderFile
-
- Call Open('Master',Strip(OutFile),Write)
- Call Open('Fil',Strip(HeaderFile),Read)
- Do While ~eof('Fil')
- Call Writeln('Master',ReadLn('Fil'))
- End
- Call Close('Fil')
- Return 0
-
-
- /****************************************************************************/
- /* Put guides from directory in output guide */
- /****************************************************************************/
-
- AppendGuide: Procedure Expose NavneListe ItemListe UseDT input.txt
- Parse Arg MLength,Skuffe,AppendType
-
- Code3='03'x
- If Words(NavneListe)=0 Then
- Return 0
- Count=1
- Call QuickSort(1,Words(NavneListe))
- Soejler=Trunc(60/(MLength+2))
- Spc=Copies(' ',trunc(60/soejler)-MLength)
- Do While Count<=Words(NavneListe)
- Linie=' '
- Do i=1 to Soejler While Count<=Words(NavneListe)
- If AppendType='GUIDE' Then
- If Right(Word(NavneListe,Count),1)=Code3 Then
- Linie=Linie||'@{@{b}'Left(StripM(Word(NavneListe,Count)),MLength,' ')'" Link "'Skuffe||StripM(Word(ItemListe,Count))||'/Main"@{ub}}'||Spc
- Else
- Linie=Linie||'@{"'Left(StripM(Word(NavneListe,Count)),MLength,' ')'" Link "'Skuffe||StripM(Word(ItemListe,Count))||'/Main"}'||Spc
- Else
- Linie=Linie||'@{"'Left(StripM(Word(NavneListe,Count)),MLength,' ')'" Link "'Compress(StripM(Word(ItemListe,Count)),'/:')||'"}'||Spc
- Count=Count+1
- End
- Call Writeln('Master',Linie)
- End
- Return 0
-
-
- /****************************************************************************/
- /* End of outputguide */
- /****************************************************************************/
-
- EndGuide: Procedure
- Parse Arg EndFile
-
- Call Open('Fil',Strip(EndFile),Read)
- Do While ~eof('Fil')
- Call Writeln('Master',ReadLn('Fil'))
- End
- Call Close('Fil')
- Call Close('Master')
- Return 0
-
-
- /****************************************************************************/
- /* Prints Progress-report */
- /****************************************************************************/
-
- Progress: Procedure
- Parse Arg Drawer
-
- Say 'Examining 'Drawer
- Return 0
-
-
- /****************************************************************************/
- /* Replaces the builtin showdir, so filenames with ' ' are ok */
- /****************************************************************************/
-
- MShowdir: Procedure
- Parse Arg Skuffe,Type
-
- Code1='01'x
- Code2='02'x
- Liste=ShowDir(Skuffe,Type,Code1)
- Start=1
- Do While Pos(' ',Liste,Start)~=0
- Start=Pos(' ',Liste,Start)+1
- Liste=OverLay(Code2,Liste,Start-1)
- End
- Start=1
- Do While Pos(Code1,Liste,Start)~=0
- Start=Pos(Code1,Liste,Start)+1
- Liste=OverLay(' ',Liste,Start-1)
- End
- Return Liste
-
-
- /****************************************************************************/
- /* Strips of the special code put in to save spaces in filenames */
- /****************************************************************************/
-
- StripM: Procedure
- Parse Arg Ord
-
- Code2='02'x
- Start=1
- Do While Pos(Code2,Ord,Start)~=0
- Start=Pos(Code2,Ord,Start)+1
- Ord=OverLay(' ',Ord,Start-1)
- End
- Return Ord
-
-
- /****************************************************************************/
- /* QuickSort of String */
- /****************************************************************************/
-
- QuickSort: Procedure Expose NavneListe ItemListe
- Parse Arg Venstre,Hoejre
-
- i=0
- Sidste=0
- If Venstre>=Hoejre Then
- Return 0
- Call Swap(Venstre,Trunc((Venstre + Hoejre)/2))
- Sidste=Venstre
- Do i=Venstre+1 to Hoejre
- If Upper(StripM(Word(NavneListe,i))) < Upper(StripM(Word(NavneListe,Venstre))) Then
- Do
- Sidste=Sidste+1
- Call Swap(Sidste,i)
- End
- End
- Call Swap(Venstre,Sidste)
- Call QuickSort(Venstre,Sidste-1)
- Call QuickSort(Sidste+1,Hoejre)
- Return 0
-
- Swap: Procedure Expose NavneListe ItemListe
- Parse Arg LN,RN
-
- Temp=Word(NavneListe,LN)
- NavneListe=Left(NavneListe,WordIndex(NavneListe,LN)-1)||' '||Word(NavneListe,RN)||Right(NavneListe,Length(NavneListe)-(WordIndex(NavneListe,LN)+WordLength(NavneListe,LN)-1))
- NavneListe=Left(NavneListe,WordIndex(NavneListe,RN)-1)||' '||Temp||Right(NavneListe,Length(NavneListe)-(WordIndex(NavneListe,RN)+WordLength(NavneListe,RN)-1))
- Temp=Word(ItemListe,LN)
- ItemListe=Left(ItemListe,WordIndex(ItemListe,LN)-1)||' '||Word(ItemListe,RN)||Right(ItemListe,Length(ItemListe)-(WordIndex(ItemListe,LN)+WordLength(ItemListe,LN)-1))
- ItemListe=Left(ItemListe,WordIndex(ItemListe,RN)-1)||' '||Temp||Right(ItemListe,Length(ItemListe)-(WordIndex(ItemListe,RN)+WordLength(ItemListe,RN)-1))
- NavneListe=Space(NavneListe,1)
- ItemListe=Space(ItemListe,1)
- Return 0
-
-
- /****************************************************************************/
- /* Control-C control */
- /****************************************************************************/
-
- BREAK_C:
- Say ('There there, easy now, I was in the middle of something here...')
- Call Closeport('MasterGuide')
- Exit 10
-
- SYNTAX:
- Say ('The output file is currently in use!')
- Call Closeport('MasterGuide')
- Exit 10
-